import requests


headers = {
    "Accept": "text/plain, */*; q=0.01",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    "Origin": "http://202.127.45.18",
    "Proxy-Connection": "keep-alive",
    "Referer": "http://202.127.45.18/Default_SeedSalePrice",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36",
    "X-FineUI-Ajax": "true",
    "X-Requested-With": "XMLHttpRequest"
}
cookies = {
    ".AspNetCore.Antiforgery.6ZHrNEKEsSU": "CfDJ8C_l1gfanBNJgCf-P6QHd6SOLhMka278gJvb3zUXxcsLaL9a3Ox3y__dFNbO5jdk4sdqrmuwvBz498kJ18aLIAEhsD9RzYFnz_Jm7jL4dUE_Zv_9gQkoqu_c2HQ_0pevwJqvaTCEW_iNrs4f-AyAM8E"
}
url = "http://202.127.45.18/xinjiangbt/Default_SeedSalePrice"
params = {
    "handler": "DoSearchPaging"
}
data = {
    "zuowu": "1",
    "zuowuMin": "47",
    "breedName": "",
    "StartDate": "2025-04-07",
    "EndDate": "2025-04-07",
    "province": "",
    "zuowu_text": "玉米",
    "zuowuMin_text": "大田玉米",
    "__RequestVerificationToken": "CfDJ8C_l1gfanBNJgCf-P6QHd6TmhPfBnkO-SaeTYy-wq7JneYMc-EerJ0ONd8vaW9nwiMmI-gepPiJ495XGmKpwpHV8g6adGPmDo132yVc8ADTWvtFQi0cRG6YxIJyauqE-Bm99rDKgmqYWLCz5sOJqeEw"
}
response = requests.post(url, headers=headers, cookies=cookies, params=params, data=data, verify=False)

data_URL = response.text.split("'")[1]
print(data_URL)
from urllib.parse import unquote
import json

decoded_str = unquote(data_URL)

# 转换为 JSON 对象
data = json.loads(decoded_str)
count = 0
# 打印前5条记录
for item in data:
    count += 1
    print(
        f"第{count}条记录, 类别: {item['category_name']},子类别: {item['child_category_name']}, 品种: {item['breed_name']}, 规格: {item['standard_name']}, 价格: {item['ave_price']}元")
